<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../css/10-Common.css">
    <link rel="stylesheet" href="../css/10-index.css">
    <link rel="stylesheet" href="../css/media.css">
    <link rel="stylesheet" href="../css/10-nostyle.css">
    <link rel="stylesheet" href="../js/template.js">
    <title>Document</title>
</head>

<body>
    <div class="hot1">&nbsp;&nbsp;平板电脑最新评论</div>
    <div class="container">
        <ul class=" index-menu">
        </ul>
    </div>
    <div class="index-menu1"></div>
    <script src="../js/10-index.js"></script>
</body>
<!-- 模板文件 -->
<script src="../lib/jquery-1.12.4.min.js"></script>
<script type="text/template" id="menuTemplate">
    {{each result as val key}}
    <li class="dropdown clearfix dropdown-13">
        <a href="#" class="dropdown-a">
            <div class="productImg clearfix">{{val.productImg}}</div>
        </a>
        <div class="productName ">{{val.productName }}</div>
    </li>
    {{/each}}
</script>
<script type="text/template" id="menuTemplate1">
    {{each result as val key}}
    <div class="comName">{{val.comName}}: ☆☆☆☆☆ <span class="comTime">{{val.comTime}}</span></div>
    <div>{{val.comContent}}</div>
    {{/each}}
</script>
<script>
    // render();
    // render1();
    // render1();



    // function render1() {
    //     $.ajax({
    //         url: 'http://193.112.55.79:9090/api/getproductcom',
    //         type: 'get',
    //         dataType: 'json',
    //         data: {
    //             productid: 5
    //         },
    //         success: function(res) {
    //             console.log(res);
    //             template.config('escape', false)
    //             if (res) {
    //                 var htmlStr = template('menuTemplate1', res);
    //                 // 动态渲染数据
    //                 $('.index-menu1').html(htmlStr);
    //             }
    //         }
    //     })
    // }
    $(function() {
        // 获取url的 参数

        function getUrl(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg); //匹配目标参数
            if (r != null) return unescape(r[2]);
            return null; //返回参数值
        }
        var id = getUrl('id')
        console.log(id);
        render();
        render1()

        function render() {
            $.ajax({
                url: 'http://193.112.55.79:9090/api/getproductcom',
                type: 'get',
                dataType: 'json',
                data: {
                    productid: id
                },
                success: function(res) {
                    console.log(res);
                    template.config('escape', false)
                    if (res) {
                        var htmlStr = template('menuTemplate1', res);
                        console.log(htmlStr);

                        // 动态渲染数据
                        $('.index-menu1').html(htmlStr);
                    }
                }
            })
        }

        function render1() {
            $.ajax({
                url: ' http://193.112.55.79:9090/api/getbrandproductlist',
                type: 'get',
                dataType: 'json',
                data: {
                    brandtitleid: 5
                },
                success: function(res) {
                    console.log(res);
                    template.config('escape', false)
                    if (res) {
                        var htmlStr = template('menuTemplate', res);
                        // 动态渲染数据
                        $('.index-menu').html(htmlStr);
                    }
                }
            })
        }
    })
</script>
<script src="../lib/template.js"></script>
<script src="../lib/jquery-1.12.4.min.js"></script>

</html>